/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.friend;

import cn.ac.iie.di.global.GlobalParas;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.fs.GlobPattern;

/**
 *
 * @author Austin
 */
public class RetryTask implements Runnable {

    static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(RetryTask.class.getName());

    ;

    @Override
    public void run() {
        ArrayList<String> jsonList = null;
        logger.info("RetryTask start");
        try {
            while (true) {
                logger.info("RetryTask run");
                Thread.sleep(120000);
                int size = GlobalParas.retryQueue.size();
                if (size == 0) {
                    continue;
                }
                logger.info("retry size is: " + size);
                for (int i = 0; i < size; ++i) {
                    //logger.info("try "+i);
                    String str = GlobalParas.retryQueue.poll(500, TimeUnit.MILLISECONDS);
                    if (str == null) {
                        break;
                    }
                    logger.info("retry: " + str);
                    GlobalParas.jsonQueue.put(str);
                }
            }
        } catch (Exception e) {
            logger.error("RetryTask class error : " + e, e);
        }

    }

}
